package com.lmq

import org.apache.log4j.{Level, Logger}
import org.apache.spark.sql.{DataFrame, SparkSession}
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.streaming.{Seconds, StreamingContext}

object InitStreamingContext {

  Logger.getLogger("org.apache.spark").setLevel(Level.WARN)

  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setAppName(this.getClass.getName).setMaster("local[*]")
    // conf: SparkConf, batchDuration: Duration
    val ssc = new StreamingContext(conf, Seconds(1))
    println(conf.toDebugString)
  }

  /**
   * creating streamingContext from existing SparkContext object.
   */
  def createSCfromEXSC(): Unit = {

    val spark: SparkSession = SparkSession.builder()
      .master("local[*]")
      .appName("Test")
      .getOrCreate()

    val ssc: StreamingContext = new StreamingContext(spark.sparkContext, Seconds(1))

  }

}
